package io.fivefire.base.common.enums;

import java.util.List;

/**
 * @Author: Sjy
 * @Date: 2018/5/30 下午10:17
 */
public enum BooleanEnum  implements IndexedEnum {

    /* 是 */
    TRUE(1, true),

    /* 否 */
    FALSE(0, false);


    private static final List<BooleanEnum> INDEXES = IndexedEnumUtil.toIndexes(BooleanEnum.values());
    // 成员变量
    private boolean aBoolean;
    private int code;

    // 构造方法
    BooleanEnum(int code, boolean aBoolean) {
        this.aBoolean = aBoolean;
        this.code = code;
    }

    public static BooleanEnum codeOf(final int code) {
        return IndexedEnumUtil.valueOf(INDEXES, code);
    }

    public boolean bool() {
        return aBoolean;
    }


    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getName() {
        return String.valueOf(bool());
    }
}
